package com.neusoft.demo5;

public class Duck extends Animal {

    public Duck(String name, int legNum) {
        super(name, legNum);
    }

    @Override
    public void shout() {
        System.out.println("嘎嘎......");
    }

    public static void main(String[] args) {
        Cat cat = new Cat("tom",4);
        Duck duck = new Duck("小黄",2);
        Animal[] animals = new Animal[2];
        animals[0] = cat;
        animals[1] = duck;

        for(int i = 0;i<animals.length;i++) {
           Animal animal = animals[i];
            System.out.println(animal.getName() + "---" + animal.getLegNum());
        }
    }
}
